Purchases
Entry point for Purchases. It should be instantiated as soon as your app has a unique user id for your user. This can be when a user logs in if you have accounts or on launch if you can generate a random user identifier. Make sure you follow the quickstart guide to setup your RevenueCat account.
Types
Functions
Creates a support ticket for the current user. Coroutine friendly version of Purchases.createSupportTicket.
Gets the current user's CustomerCenterConfigData. Used by RevenueCatUI to present the customer center.
Get latest available customer info. Coroutine friendly version of Purchases.getCustomerInfo.
Fetches the virtual currencies for the current subscriber.
This function will change the current appUserID. Typically this would be used after a log out to identify a new user without calling configure
Logs out the Purchases client clearing the save appUserID. This will generate a random user id and save it in the cache.
This method will try to obtain the Store (Google/Amazon) locale. Note: this locale only has a region set. If there is any error, it will return null and log said error. Coroutine friendly version of Purchases.getStorefrontLocale.
Syncs subscriber attributes and then fetches the configured offerings for this user. This method is intended to be called when using Targeting Rules with Custom Attributes. Any subscriber attributes should be set before calling this method to ensure the returned offerings are applied with the latest subscriber attributes.
This method will send all the purchases to the RevenueCat backend. Call this when using your own implementation for subscriptions anytime a sync is needed, such as when migrating existing users to RevenueCat.
Note: This method only works for the Amazon Appstore. There is no Google equivalent at this time. Calling from a Google-configured app will always return AmazonLWAConsentStatus.UNAVAILABLE.
Note: This method only works for the Amazon Appstore. There is no Google equivalent at this time. Calling from a Google-configured app will always return AmazonLWAConsentStatus.UNAVAILABLE.
Get latest available customer info.
Get customer info from cache or network depending on fetch policy.
Fetch the configured offerings for this users. Offerings allows you to configure your in-app products vis RevenueCat and greatly simplifies management. See the guide for more info.
Gets the StoreProduct(s) for the given list of product ids for all product types.
Gets the StoreProduct(s) for the given list of product ids of type type
This method will try to obtain the Store (Google/Amazon) country code in ISO-3166-1 alpha2. If there is any error, it will return null and log said error.
This method will try to obtain the Store (Google/Amazon) locale. Note: this locale only has a region set. If there is any error, it will return null and log said error.
Fetches the virtual currencies for the current subscriber.
This function will change the current appUserID. Typically this would be used after a log out to identify a new user without calling configure
Logs out the Purchases client clearing the save appUserID. This will generate a random user id and save it in the cache.
Make a purchase. If purchasing a subscription, it will choose the default SubscriptionOption.
Purchase product. If purchasing a subscription, it will choose the default SubscriptionOption.
Call this when you are finished using the UpdatedCustomerInfoListener. You should call this to avoid memory leaks.
Restores purchases made with the current Play Store account for the current user. This method will post all active subscriptions and non consumed one time purchases associated with the current Play Store account to RevenueCat and become associated with the current appUserID. If the receipt token is being used by an existing user, the current appUserID will be aliased together with the appUserID of the existing user. Going forward, either appUserID will be able to reference the same user.
Google Play only, no-op for Amazon. Displays the specified in-app message types to the user as a snackbar if there are any available to be shown. If PurchasesConfiguration.showInAppMessagesAutomatically is enabled, this will be done automatically on each Activity's onStart.
Updates the current appUserID to a new one, without associating the two.
Syncs subscriber attributes and then fetches the configured offerings for this user. This method is intended to be called when using Targeting Rules with Custom Attributes. Any subscriber attributes should be set before calling this method to ensure the returned offerings are applied with the latest subscriber attributes.
This method will send all the purchases to the RevenueCat backend. Call this when using your own implementation for subscriptions anytime a sync is needed, such as when migrating existing users to RevenueCat. The onSuccess callback will be called if all purchases have been synced successfully or there are no purchases. Otherwise, the onError callback will be called with a PurchasesError indicating the first error found.
Properties
The passed in or generated app user ID
The listener is responsible for handling changes to customer information. Make sure removeUpdatedCustomerInfoListener is called when the listener needs to be destroyed.